# (decoded with TMPL 11972) { %filename% } { Created %date% %time% by AppMaker } Unit %unitname%; Interface Uses %If MPW% {$Load ToolBox.dump} MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf, {$Load} %end if% %If Think% {$ifc undefined Think_Pascal} ListManager, {$endc} %end if% %UsesFiles% Globals, ResourceDefs; {----------} Procedure InitTitles; Procedure LoadMenus; Procedure DoMenu (menuChoice: longint); Procedure UpdateMenus; {----------} Implementation %If MPW% {$D+} {$R+} {$OV+} %end if% %If MPW% {$S %unitname%} %end if% {----------} Procedure InitTitles; Begin %InitTitles% End; {InitTitles} {----------} Procedure LoadMenus; Begin %GetMenus% %InsertMenus% DrawMenuBar; End; {LoadMenus} {----------} Procedure DoAbout; var itemNr: integer; Begin itemNr := Alert (AboutID, nil); End; {DoAbout} {----------} Procedure DoApple (itemNr: integer); var name: Str255; refNum: integer; Begin case itemNr of AppleAbout: DoAbout; otherwise begin GetItem (AppleMenu, itemNr, name); refNum := OpenDeskAcc (name); end; end; {case} End; {DoApple} {----------} Procedure DoMenu {(menuChoice: longint)}; var menuID: integer; itemNr: integer; Begin menuID := HiWord (menuChoice); itemNr := LoWord (menuChoice); case menuID of 0: {Do nothing}; %HandleMenus% end; {case} HiliteMenu (0); End; {DoMenu} {----------} Procedure UpdateMenus; var frontPeek: WindowPeek; isFront: boolean; {is there a front window?} isCur: boolean; {is there a current window?} isDirty: boolean; {is it dirty?} hasFile: boolean; {does it have a file?} isSelected: boolean; {is anything selected?} isDesk: boolean; {is the front window a desk acc?} isText: boolean; {is there a current text field?} isScrap: boolean; {is there any scrap?} menu: MenuHandle; menuBarChanged: boolean; {----------} Procedure Enable (itemNr: integer; enabled: boolean); Begin if enabled then begin EnableItem (menu, itemNr); end else begin DisableItem (menu, itemNr); end; End; {Enable} {----------} Procedure EnableTitle (menu: MenuHandle; enabled: boolean); Begin if enabled <> odd (menu^^.enableFlags) then begin menuBarChanged := true; end; if enabled then begin EnableItem (menu, 0); end else begin DisableItem (menu, 0); end; End; {EnableTitle} Begin {UpdateMenus} menuBarChanged := false; isFront := (FrontWindow <> nil); isCur := (curWindow <> nil); isDirty := false; hasFile := false; isSelected := false; if isCur then begin isDirty := cur^.dirty; HasFile := (cur^.fileNum <> 0); end; isDesk := false; if isFront then begin frontPeek := WindowPeek (FrontWindow); isDesk := (frontPeek^.windowKind < 0); end; isText := false; if isCur then begin isText := (cur^.text <> nil); end; isScrap := false; if isText then begin isSelected := (cur^.text^^.selStart <> cur^.text^^.selEnd); isScrap := (TEGetScrapLen > 0); end; menu := FileMenu; %if defined FileClose% Enable (FileClose, isFront); %end if% %if defined FileSave% Enable (FileSave, isDirty); %end if% %if defined FileSaveAs% Enable (FileSaveAs, isDirty); %end if% %if defined FileRevert% Enable (FileRevert, isDirty and hasFile); %end if% menu := EditMenu; if isFront then begin %if defined EditUndo% Enable (EditUndo, isDesk); %end if% %if defined EditCut% Enable (EditCut, isDesk or isSelected); %end if% %if defined EditCopy% Enable (EditCopy, isDesk or isSelected); %end if% %if defined EditPaste% Enable (EditPaste, isDesk or isScrap); %end if% %if defined EditClear% Enable (EditClear, isDesk or isSelected); %end if% %if defined EditSelectAll% Enable (EditSelectAll, isText); %end if% end; EnableTitle (EditMenu, isFront); if menuBarChanged then begin DrawMenuBar; end; End; {UpdateMenus} End. {%unitname%}